<!DOCTYPE html>
<include file="Public:header"/>
<script type="text/javascript">
    var UEURL = '__ROOT__/Public/Plugin/umeditor/';
</script>
<link href="__PUBLIC__/Plugin/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/Plugin/umeditor/third-party/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Plugin/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Plugin/umeditor/umeditor.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Plugin/layDate/laydate/laydate.js"></script>
<script type="text/javascript" src="__PUBLIC__/Plugin/umeditor/lang/zh-cn/zh-cn.js"></script>

<link href="__PUBLIC__/Theme1/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="__PUBLIC__/Theme1/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="__PUBLIC__/Theme1/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="__PUBLIC__/Theme1/css/animate.min.css" rel="stylesheet">
<link href="__PUBLIC__/Theme1/css/style.min.css?v=4.1.0" rel="stylesheet">
<link href="__PUBLIC__/Plugin/style/css/common.css" type="text/css" rel="stylesheet">
<link href="__PUBLIC__/Plugin/style/css/index.css" type="text/css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加(修改)商品
                        <small></small>
                    </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="post" action="__URL__/activityGoodadd" class="form-horizontal" enctype="multipart/form-data" onsubmit="return my_check();">
                        <input type="hidden" value="{$result.id}" name="id">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="title" id="url" required placeholder="请输入标题" value="{$result.title}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">原价</label>
                            <div class="col-sm-2">
                                <input type="number" class="form-control" name="yuanjia" id="name" placeholder="原价"
                                       value="{$result.yuanjia}" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">现价</label>
                            <div class="col-sm-2">
                                <input type="number" class="form-control" name="xianjia" id="name" placeholder="现价"
                                       value="{$result.xianjia}" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品详情</label>
                            <div class="col-sm-6">
                                <div type="text/plain" id="myEditor1" name="con"
                                     style="width:660px;height:240px;">
                                    {$result['con']}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片</label>
                            <div class="col-sm-3">
                                <div class="z_photo upimg-div clear" >
                                    <strong>点击图片删除</strong>
                                    <div id="preview" onclick="uploadpic()"></div>
                                    <if condition="($result.img neq '')">
                                        <div id='wxpic' onclick="uploadpic()">
                                            <img class="re" style="padding: 0px 0px 6px 0px;max-width:80px;max-height:80px;" src="{$PATH}{$result.img}"/>
                                            <input type="hidden" name="img" value="{$result.img}">
                                        </div>
                                        <else/>
                                        <img class="re" style="padding: 0px 0px 6px 0px;max-width:200px;max-height:200px;" id="pic_url" name="img" src=""/>
                                    </if>

                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-5">
                                <span class="btn btn-primary">上传</span>
                                <input type="file" style="width: 55px;position: relative;left: 0;z-index: 15;height: 35px;top: -30px;opacity: 0;float: none;"
                                       name="img1" value="" onchange="previewImage(this)">
                            </div>

                        </div>
        
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <a class="btn btn-white" href="{:U('Admin/Good/activityGood')}">返回</a>
                            </div>
                        </div>
                        <!--<input type="hidden" value="{$result.image}" id="images">-->
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Theme1/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Theme1/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Theme1/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Theme1/js/plugins/iCheck/icheck.min.js"></script>
<script src="__PUBLIC__/Plugin/style/js/imgUp.js"></script>
<script>

    //实例化编辑器
    var um1 = UM.getEditor('myEditor1');

    laydate.render({
        elem: '#start_time' //指定元素
    });
    laydate.render({
        elem: '#end_time' //指定元素
    });
    $(document).ready(function () {
        var long = $("#long").val();
        if (long == 1) {
            $(".form-group.time").hide();
        } else {
            $(".form-group.time").show();
        }


    });
    $('input:radio[name="long"]').change(function () {
        if ($(this).is(":checked")) {
            if ($(this).val() == 1) {
                $(".form-group.time").hide();
            } else {
                $(".form-group.time").show();
            }

        } else {
            alert(0);
        }
    });
    $(".form-group.people").hide();
    $('input:radio[name="all_people"]').change(function () {
        if ($(this).is(":checked")) {
            if ($(this).val() == 1) {
                $(".form-group.people").hide();
                $(".form-group.chose").hide();
            } else {
                $(".form-group.people").show();
                $(".form-group.chose").show();
            }

        } else {
            alert(0);
        }
    });
//输入搜索群组
    function search_group() {
        var search=$("#text").val();
        var html=''
        console.log(search);
        $.ajax({
            url:"__CONTROLLER__/searchGroup",
            data:{"search":search},
            dataType:"json",
            type:"post",
            success:function (res) {
                console.log(res.data);
                if(res.state==1){
                for (var i in res.data){
                    html+='<input name="group_id[]" type="checkbox"value="'+res.data[i]["id"]+'">'+res.data[i]['name'];

                }
                    $('.showuser').html('');
                $('.showuser').html(html)
            }else{
                    $('.showuser').html('');
                }
 }

        })
    }

    //删除轮播图片
    function delPic() {
        var a = $(".del_id").val();
        console.log(a);
    }
    function previewImage(file) {
        var prevDiv = document.getElementById('preview');
        if (file.files && file.files[0]) {
            var reader = new FileReader();
            reader.onload = function (evt) {
                prevDiv.innerHTML = '<img style="width: 200px;height: 200px" class="re" src="' + evt.target.result + '" />';
                $("#wxpic").next("input").remove();
                $("#wxpic").remove();
            }
            reader.readAsDataURL(file.files[0]);
        } else {
            prevDiv.innerHTML =
                '<div class="re" style="width: 200px;height: 200px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
            $("#wxpic").next("input").remove();
            $("#wxpic").remove();
        }
    }
    function uploadpic() {
        $("#wxpic").next("input").remove();
        $("#wxpic").remove();
        $(".re").attr("src", "");
        $(".re").attr("style", "display:none");
    };

</script>
</body>

</html>
